package cn.gqr.entity;

import cn.gqr.uitl.SessionUitl;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Document("t_blog")
public class Blog {

    @Id
    private String id; //id

    private String uid; //用户id
    private String title;   //文章标题

    @Field("text_id")
    private String textId; //文章内容id

    @Field("posted_time")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm",timezone = "GMT")
    private Date postedTime = new Date();  //发表时间

    private String digest; //摘要

    private String like = "0";    //点赞

    @Field("read_count")
    private int readCount = 0;  //阅读量

    @Field("type_id")
    private String typeId; //类别

    @Field("collect_num")
    private int collectNum = 0; //收藏量


    public int getCollectNum() {
        return collectNum;
    }

    public void setCollectNum(int collectNum) {
        this.collectNum = collectNum;
    }

    public String getTypeId() {
        return typeId;
    }

    public void setTypeId(String typeId) {
        this.typeId = typeId;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTextId() {
        return textId;
    }

    public void setTextId(String textId) {
        this.textId = textId;
    }

    public Date getPostedTime() {
        return postedTime;
    }

    public void setPostedTime(Date postedTime) {
        this.postedTime = postedTime;
    }

    public String getLike() {
        return like;
    }

    public void setLike(String like) {
        this.like = like;
    }

    public int getReadCount() {
        return readCount;
    }

    public void setReadCount(int readCount) {
        this.readCount = readCount;
    }

    public String getDigest() {
        return digest;
    }

    public void setDigest(String digest) {
        this.digest = digest;
    }

    @Override
    public String toString() {
        return "Blog{" +
                "id='" + id + '\'' +
                ", uid='" + uid + '\'' +
                ", title='" + title + '\'' +
                ", textId='" + textId + '\'' +
                ", postedTime=" + postedTime +
                ", digest='" + digest + '\'' +
                ", like='" + like + '\'' +
                ", readCount=" + readCount +
                ", typeId='" + typeId + '\'' +
                ", collectNum=" + collectNum +
                '}';
    }
}
